<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>心理咨询预约系统</title>
    <script type="text/javascript" src="__USER__/js/jquery-1.8.0.js"></script>
    <!--    <script type="text/javascript" src="__USER__/jq/jquery.md5.js"></script>-->
    <script src="__USER__/js/layui/layui.js"></script>
    <link rel="stylesheet" href="__USER__/js/layui/css/layui.css">
    <link rel="stylesheet" href="__USER__/css/base.css">
    <link rel="stylesheet" href="__USER__/css/page/head.css">
    <link rel="stylesheet" href="__USER__/css/page/foot.css">
    <link rel="stylesheet" href="__USER__/css/page/index.css">
</head>
<body>
<div class="head-box">
    <div class="head-tit layui-row">
        <div class="headTit-inner layui-col-md-offset2 layui-col-md8">
            <div class="fl headTit-left">
                <div class="logo fl" style="margin-left: -40%">
                    <img src="__USER__/img/logo.png">
                </div>
                <div class="tit-txt fl" style="margin-left: -25%">
                    <div class="head-tit-bg"><a href="index.html">预约咨询服务平台</a></div>
                    <div class="head-tit-sm">预约诊疗服务平台</div>
                </div>
            </div>
            <div class="fr headTit-right layui-row" style="width: 500px">
                <ul>
                    <li class="layui-nav-item" style="margin-left:95%;margin-top:2%;width: 700px">
                        <a href="../student/info.html"><span style="font-size: 14px; color: #010101">欢迎,   </span><span
                                style="font-size: 20px; color: #0f6bed">   {$Request.session.studentname}   </span> </a>
                        <a style="text-decoration: none" href="javascript:void(0);" onclick="message()"><i
                                class="layui-icon layui-icon-notice"
                                title="消息"><span style="font-size: 14px; color: #2BC807">（{$count}）</span></i></a>

                        <a href="../student/logout"> <span style="font-size: 14px; color: #010101">    ,   退出</span></a>
                    </li>
                </ul>
                <div class="layui-row">

                </div>
            </div>
        </div>
    </div>

    <div class="head-tab layui-row">
        <div class="headTab-inner layui-col-md-offset2 layui-col-md8">
            <ul class="headTab-ul">
                <li>
                    <a href="order.html">预约咨询</a>
                </li>
                <li>
                    <a href="info.html">个人中心</a>
                </li>
                <li>
                    <a href="myorder.html">我的预约</a>
                </li>
                <li>
                    <a href="know.html">了解教师</a>
                </li>
                <li>
                    <a href="message.html">留言建议</a>
                </li>
            </ul>
        </div>
    </div>
</div>
<hr class="hr20">
<div class="layui-form" style="font-size: 15px">
    <div>
        <div style="font-family: 楷体;font-size: 30px;margin-left: 44%">个人信息修改</div>
        <hr class="hr15">
        <div class="layui-form-item" style="font-family: Consolas; margin-left: 35%">
            <label class="layui-form-label">照片</label>
            <a class="layui-btn" id="image" style="float: left;"><i class="layui-icon">&#xe67c;</i>上传图片</a>
            <div class="layui-input-block" style="margin-left: 220px;">
                <input type="text" name="img" class="layui-input" placeholder="请上传一寸证件照"
                       style="position: absolute;left: 0;top: 0; width: 150px">
            </div>
            <br/>
            <div class="layui-form-item">
                <img style="width: 147px;height: 206px; margin-left: 168px;border:1px solid black" id="img"
                     src="{$photo}">
            </div>
        </div>

        <div class="layui-form-item " style="font-family: Consolas; margin-left: 28%">
            <div class="layui-inline">
                <label class="layui-form-label">学号：</label>
                <div class="layui-input-inline">
                    <input type="text" id="id" name="id" lay-verify="required" autocomplete="off"
                           disabled="disabled" class="layui-input" value="{$id}">
                </div>
            </div>
            <div class="layui-inline">
                <label class=" layui-form-label ">姓名：</label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" lay-verify="required|expertname" autocomplete="off"
                           class="layui-input" value="{$name}">
                </div>
            </div>
        </div>

        <div class="layui-form-item" style="font-family: Consolas; margin-left: 28%">
            <div class="layui-inline">
                <label class="layui-form-label">密码：</label>
                <div class="layui-input-inline">
                    <input type="text" id="password" name="password" lay-verify="required|password" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">年龄：</label>
                <div class="layui-input-inline">
                    <input type="text" id="age" name="age" lay-verify="require|agecheck" autocomplete="off"
                           class="layui-input" value="{$age}">
                </div>
            </div>
        </div>
        <div class="layui-form-item" style="font-family: Consolas; margin-left: 28%">
            <div class="layui-inline">
                <label class="layui-form-label">性别：</label>
                <div class="layui-input-inline">
                    <select id="sex" name="sex" lay-verify="required" autocomplete="off" class="layui-input">
                        {volist name="sexlist" id="vo" key="k"}
                        {eq name="vo" value="$sex"}
                        <option value="{$vo.sex}" selected>{$vo.sex}</option>
                        {else/}
                        <option value="{$vo.sex}">{$vo.sex}</option>
                        {/eq}
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">民族：</label>
                <div class="layui-input-inline">
                    <input type="text" id="nation" name="nation" lay-verify="required" autocomplete="off"
                           class="layui-input" value="{$nation}">
                </div>
            </div>
        </div>
        <div class="layui-form-item" style="font-family: Consolas; margin-left: 28%">
            <div class="layui-inline">
                <label class="layui-form-label">地址：</label>
                <div class="layui-input-inline">
                    <input type="text" id="address" name="address" lay-verify="required" autocomplete="off"
                           class="layui-input" value="{$address}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">学院：</label>
                <div class="layui-input-inline">
                    <select id="depart" name="depart" lay-verify="required" autocomplete="off" class="layui-input">
                        {volist name="departlist" id="vo" key="k"}
                        {eq name="vo" value="$depart"}
                        <option value="{$vo.depart}" selected>{$vo.depart}</option>
                        {else/}
                        <option value="{$vo.depart}">{$vo.depart}</option>
                        {/eq}
                        {/volist}
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item" style="font-family: Consolas; margin-left: 28%">
            <div class="layui-inline">
                <label class="layui-form-label">手机：</label>
                <div class="layui-inline">
                    <input type="text" id="phone" name="phone" disabled="disabled" lay-verify="required"
                           autocomplete="off"
                           class="layui-input" style="width: 200px" value="{$phone}">
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">邮箱：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="mail" name="mail" lay-verify="email" autocomplete="off"
                               class="layui-input" value="{$mail}">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item" style="font-family: Consolas; margin-left: 28%">
            <div class="layui-inline">
                <label class="layui-form-label">验证码：</label>
                <div class="layui-input-inline">
                    <input type="text" id="code" name="code" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <button type="button" id="send" class="layui-btn" style="margin-left:30%">获取短信</button>
                </div>
                <div class="layui-input-inline">
                    <!--                    <a href="phone.html">更换手机</a>-->
                    <button type="button" id="change" class="layui-btn" style="margin-left:5%">更换手机</button>
                </div>
            </div>
        </div>
        <hr class="hr20">
        <div class="layui-form-item" style="font-family: Consolas;font-size: 18px; margin-left: 40%">
            <label class="layui-form-label"></label>
            <button class="layui-btn" lay-filter="update" id="update" lay-submit="update">保存修改</button>
        </div>
        <hr class="hr20">
    </div>
</div>

<div class="layui-row">
    <div class="layui-col-md-offset2 layui-col-md8">
        <div class="cardTit">
            <!-- <span class="cardTit-tit">友情链接</span> -->
        </div>
        <div class="body-card">
            <div id="linkurl" class="link-box">
            </div>
        </div>
    </div>
    <div class="layui-col-md12 foot-about">
        <div class="about-box">
            <div><a href="aboutus.html">关于我们</a></div>
            <span>|</span>
            <div><a href="yinsi.html">隐私条款</a></div>
            <span>|</span>
            <div><a href="contactus.html">联系我们</a></div>
            <div class="clear"></div>
        </div>
        <div>Copyright © 2019 - 2025 WEDOCTOR. All Rights Reserved. 苏孙举 版权所有</div>
    </div>
</div>
<script>
    var studentid = "{:session('studentid')}";

    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        var table = layui.table;
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        var flag = 0;

        //检查设置默认图片
        $(document).ready(function () {
            //消息检测
            if (flag == 0) {
                $.ajax({
                    type: "get",
                    url: "{:url('Student/checkmessage')}",
                    async: false,
                    success: function (data) {
                        console.log(data);
                        if (data != 0) {
                            layer.msg("您有（" + data + "）条新信息，请注意查看！");
                            flag = 1;
                        }
                    }
                });
            }
        });
    });

    //显示消息
    function message() {
        layer.open({
            type: 2,
            title: '',
            shadeClose: true,
            shade: 0.7,
            area: ['809px', '500px'],
            content: ['notify'],
            end: function () {
                $.ajax({
                    type: "get",
                    url: "{:url('Student/changenotify')}",
                    async: false,
                    success: function (data) {
                        console.log(data);
                        //考虑读完之后数字为0
                    }
                });
            }
        });
    }

    function yinsi() {
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            shadeClose: true,
            skin: 'yourclass',
            content: '自定义HTML内容'
        });
    }


    layui.use('layer', function () {
        var layer = layui.layer;
        $(document).ready(function () {
            $.ajax({
                type: "post",
                url: "{:url('Student/getinfo')}",
                dataType: "json",
                data: {"id": studentid},
                async: false,
                success: function (data) {
                    // console.log(data);
                    $(" input[name='id']").val(data.list3.id);
                    $(" input[name='name']").val(data.list3.name);
                    $(" input[name='password']").val(data.list3.pwd);

                    var selecctsexval;
                    var selecctlevelval;
                    var selectsex = document.getElementById("sex");
                    var selectlevel = document.getElementById("depart");
                    for (var i = 0; i < selectsex.options.length; i++) {
                        if (selectsex.options[i].value == data.list3.sex) {
                            selecctsexval = selectsex.options[i].value;
                            selectsex.options[i].selected = true;
                            $("input[name='sex']").val(selectsex.options[i].value);
                        }
                    }
                    for (var i = 0; i < selectlevel.options.length; i++) {
                        if (selectlevel.options[i].value == data.list3.depart) {
                            selecctlevelval = selectlevel.options[i].value;
                            selectlevel.options[i].selected = true;
                            $("input[name='depart']").val(selectlevel.options[i].value);
                        }
                    }
                    //下拉框必须先赋值在 选中 再渲染
                    //$(layero).find('select[name=sex]').val(selecctsexval);
                    //$(layero).find('select[name=depart]').val(selecctlevelval);
                    $(" input[name='email']").val(data.list3.mail);
                    $(" input[name='age']").val(data.list3.age);
                    $(" input[name='address']").val(data.list3.address);
                    $(" input[name='phone']").val(data.list3.phone);
                }
            });
            // layui.form.render('select');
            //  location.reload();
        });

    })


    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        var table = layui.table;
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        var code

        //自定义验证规则
        form.verify({
            expertname: [/^[\u4e00-\u9fa5]{2,4}$|^[a-zA-Z]{1,30}$/, '姓名只能为2至4个汉字或1至30个英文单词'],
            password: [/^[a-zA-Z]\w{5,17}$/, '以字母开头，长度在6~18之间，只能包含字母、数字和下划线'],
            agecheck: [/(^[1][0-5][0-5]$)|(^[1-9][0-9]$)|(^100&)|(^[1-9]$)$/, '只能输入1到155之间任意数字'],
        });


        $("#change").click(function () {
            $(window).attr('location', "phone.html");
        });


        //未实现倒计时60秒


        $("#send").click(function () {
            var name = $('#name').val();
            var password = $('#password').val();
            var sex = $('#sex').val();
            var address = $('#address').val();
            var mail = $('#mail').val();
            var age = $('#age').val();
            var nation = $('#nation').val();
            var depart = $('#depart').val();
            var tel = $('#phone').val();

            if (name == '' || password == '' || address == '' || age == '' || nation == '' || mail == '') {
                layer.msg("请填完全部信息再获取验证码！")
            } else {
                $.ajax({
                    type: "post",
                    dataType: "json",
                    data: {"tel": tel},
                    url: "{:url('Student/sms')}",
                    async: false,
                    success: function (data) {
                        var obj = JSON.parse(data);
                        code = obj.uid;
                        // console.log(obj);
                        // console.log(obj.uid);
                        // console.log(obj.code);
                        if (obj.code == '000000') {
                            layer.msg("发送成功!", {icon: 1, time: 1000}, function () {
                                setTimeout('', 100);
                            });
                            //layer.msg("发送成功!");
                        } else if (obj.code == '105147') {
                            layer.msg("当前手机号发送次数超过限制，请过段时间后重试！", {icon: 2, time: 1000}, function () {
                                setTimeout('', 100);
                            });
                            // layer.msg("当前手机号发送次数超过限制，请过段时间后重试！");
                        }
                    }
                });
            }
        });


        $("#update").click(function () {
            var sms = $('#code').val();

            var id = $('#id').val();
            var name = $('#name').val();
            var password = $('#password').val();
            var sex = $('#sex').val();
            var address = $('#address').val();
            var mail = $('#mail').val();
            var age = $('#age').val();
            var nation = $('#nation').val();
            var depart = $('#depart').val();
            var phone = $('#phone').val();

            // console.log(name);
            // console.log(password);
            // console.log(sex);
            // console.log(address);
            // console.log(mail);
            // console.log(age);
            // console.log(nation);
            // console.log(depart);
            // console.log(phone);

            if (sms == code) {
                $.ajax({
                    type: "post",
                    url: "../Student/update",
                    dataType: "json",
                    data: {
                        "id": id, "name": name, "pwd": password, "sex": sex, "mail": mail, "age": age,
                        "depart": depart, "address": address, "phone": phone, "nation": nation
                    },
                    async: false,//必须是同步提交的
                    success: function (data) {
                        console.log(data.data);
                        if (data.data == 1) {
                            $.ajax({
                                type: "post",
                                url: "{:url('Student/info')}",
                                async: false,
                                success: function (data) {
                                }
                            });
                            layer.msg("修改成功！", {icon: 1, time: 1000}, function () {
                                setTimeout('window.location.reload()', 100);
                            });
                            // layer.msg("修改成功！");
                            // location.reload();
                        } else {
                            layer.msg("修改失败！", {icon: 2, time: 1000}, function () {
                                setTimeout('window.location.reload()', 100);
                            });
                            // layer.msg("修改失败！");
                        }

                    },
                });
            } else {
                layer.msg("验证码错误，请检查后重新输入！", {icon: 2, time: 1000}, function () {
                    setTimeout('', 100);
                });
                //layer.msg("验证码错误，请检查后重新输入！")
            }
        });
    })
    ;


    layui.use('upload', function () {
        var upload = layui.upload,
            jq = layui.jquery;
        upload.render({
            url: '{:url("Student/photo")}'
            , elem: '#image'
            , ext: 'jpg|png|jpeg'
            , area: ['500', '500px']
            , before: function (input) {
                loading = layer.load(2, {
                    shade: [0.2, '#000']
                });
            }
            , done: function (res) {
                console.log(res.src);
                layer.close(loading);
                jq('input[name=img]').val(res.path);
                img.src = "" + res.src;
                layer.msg(res.msg, {icon: 1, time: 1000});
            }
        });
    })

</script>
</body>
</html>